package com.blstudio;
import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;


    //MyAdapter Start
    //Adapter for Gridview	
    public class mainGridView extends BaseAdapter {
    	
        
    	// references to our images
    	private Integer[] mThumbIds = {
    			R.drawable.tvschedule1,
    			R.drawable.chaos,
    			R.drawable.tvschedule,
    			R.drawable.tvschedule,
    			R.drawable.tvschedule,
    			R.drawable.tvschedule,
    			R.drawable.fun,
    			R.drawable.junghwa,
    			};
    	private Integer[] mSubtitleIds = {
    			R.string.subtitle1,
    			R.string.subtitle2,
    			R.string.subtitle3,
    			R.string.subtitle4,
    			R.string.subtitle5,
    			R.string.subtitle6,
    			R.string.subtitle7,
    			R.string.subtitle8
    			
    			};
    	
        	private Activity mContext;
        																									
    		public mainGridView(Activity c) {
    			// TODO Auto-generated constructor stub
    			mContext = c;
    		}

    		public int getCount() {
    			// TODO Auto-generated method stub
    			return mThumbIds.length;
    		}

    		public Object getItem(int arg0) {
    			// TODO Auto-generated method stub
    			return mThumbIds[arg0];
    		}

    		public long getItemId(int arg0) {
    			// TODO Auto-generated method stub
    			return arg0;
    		}

    		public View getView(int position, View convertView, ViewGroup parent) {
    			// TODO Auto-generated method stub
    			
    			View grid;
    			 
    			if(convertView==null){
    				grid = new View(mContext);
    				LayoutInflater inflater= mContext.getLayoutInflater();
    				grid=inflater.inflate(R.layout.mygrid, parent, false);
    			}else{
    				grid = (View)convertView;
    			}
    			
    			ImageView imageView = (ImageView)grid.findViewById(R.id.imagepart);
    			TextView textView = (TextView)grid.findViewById(R.id.textpart);
    			imageView.setImageResource(mThumbIds[position]);
    			textView.setText(mSubtitleIds[position]);
    			
    			
    			return grid;
    			
    		}
    	} // MyAdapter ENd    